package Client.PokerClient.src;

import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

/**
 * Klasa okna tworzacej gre.
 * @author Artur Smolibowski
 */
public class CreateGameWindow extends JFrame {
  /**
   * Label.
   */
  private JLabel labHostPlay;
  /**
   * Label.
   */
  private JLabel labPlayer;
  /**
   * Lable.
   */
  private JLabel labBot;
  /**
   * Lista rozwijana z wyborem liczby graczy.
   */
  private JComboBox<String> comPlayerNumber;
  /**
   * Lista rozwijana z wyborem liczby botow.
   */
  private JComboBox<String> comBotNumber;
  /**
   * Znacznik czy gra host gry.
   */
  private JCheckBox cheHostPlay;
  /**
   * Przycisk utworzenia gry.
   */
  private JButton butCreateGame;
  /**
   * Przycisk powrotu.
   */
  private JButton butBack;
  /**
   * Konstruktor klasy.
   * @param program Okno glowne programu.
   */
  CreateGameWindow(JFrame program) {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setLayout(new GridLayout(4,2));
    this.setBounds(500, 300, 370, 200);

    String[] s = { "2", "3", "4" };
    String[] s2 = {"0", "1", "2", "3", "4" };
    comPlayerNumber = new JComboBox<String>(s);
    comBotNumber = new JComboBox<String>(s2);

    butCreateGame = new JButton("Create Game");
    butBack = new JButton("Back");

    labPlayer = new JLabel("Liczba graczy: ");
    labBot = new JLabel("Liczba botow: ");
    labHostPlay = new JLabel("Czy grasz: ");

    cheHostPlay = new JCheckBox("Tak");

    add(labPlayer);   add(comPlayerNumber);
    add(labBot);      add(comBotNumber);
    add(labHostPlay); add(cheHostPlay);
    add(butBack);     add(butCreateGame);

    setResizable(false);
    setLocationRelativeTo(null);
  }
  /**
   * Dodanie Action Listenera.
   * @param listener Listener ktory bedzie nasluchiwal.
   */
  public void addActionListener(CreateGameListener listener) {
    butCreateGame.addActionListener(listener);
    butBack.addActionListener(listener);
  }
  /**
   * Pobranie liczby graczy z listy.
   * @return Liczba Graczy.
   */
  public int getNumberOfPlayers() {
    return comPlayerNumber.getSelectedIndex()+2;
  }
  /**
   * Pobranie liczby botow z listy.
   * @return Liczba Botow.
   */
  public int getNumberOfBot() {
	return comBotNumber.getSelectedIndex();  
  }
  /**
   * Pobranie wartosci: czy host gra.
   * @return Czy host gra.
   */
  public int ifHostPlay() {
    if(cheHostPlay.isSelected())
      return 1;
    else
      return 0;
  }
  /**
   * Pobranie przycisku butCreateGame.
   * @return butCreateGame.
   */
  public JButton getCreateGame() {
    return butCreateGame;
  }
  /**
   * Pobranie przycisku butBack.
   * @return butBack.
   */
  public JButton getBack() {
    return butBack;
  }
}